import React from 'react'
import getContact from "@/ssr/getContact";
import getArticleBySlug from '@/ssr/getArticleBySlug';
import ArticleTemplate from '@/template/articles/ArticleTemplate';

export async function generateMetadata({params}) {
  const contact = await getContact();
  const {slug} = await params;
  const article = await getArticleBySlug(slug);
  return {
    title: article.meta_title ? article.meta_title : `${article.title} | ${contact.meta_title || contact.name}`,
    description: article.meta_description ? article.meta_description : `${contact.meta_description || contact.description}`,
  };
}

export default async function page({params}) {
  const {slug} = await params;
  const res = await getArticleBySlug(slug);
  return (
    <ArticleTemplate template={res.template} info={res} />
  )
}
